Enable execution without cargo in PATH
authorAlex Crichton <alex@alexcrichton.com>
Tue, 1 Jul 2014 14:55:19 +0000 (07:55 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 2 Jul 2014 02:47:18 +0000 (19:47 -0700)
This allows usage of cargo without all the executables in your PATH, you only
need to be able to reach the first one.

src/bin/cargo.rs

index ed3a12d32bd56a21150acff8663651bd655c16f4..c3577bdd8144d96ed35476942c4ff91067f9f013 100755 (executable)
@@ -56,7 +56,12 @@ fn execute() {
             println!("Options (for all commands):\n\n{}", options);
         },
         _ => {
-            let command = Command::new(format!("cargo-{}", cmd))
+            let command = format!("cargo-{}", cmd);
+            let mut command = match os::self_exe_path() {
+                Some(path) => Command::new(path.join(command)),
+                None => Command::new(command),
+            };
+            let command = command
                 .args(args.as_slice())
                 .stdin(InheritFd(0))
                 .stdout(InheritFd(1))